<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'

// 监听串口变化自动刷新
window.onresize = function () {
  location.reload()
}

setInterval(() => {
  location.reload()
}, 300000)

// 路由配置
import router from './router'; // 假设你的路由配置文件位于 ./router
import { onMounted } from 'vue';
onMounted(() => {
  const lastVisitedRoute = localStorage.getItem('lastVisitedRoute');

  if (lastVisitedRoute) {
    try {
      const route = JSON.parse(lastVisitedRoute);

      // 防止重定向到相同的路径，避免无限循环
      if (route.path !== window.location.pathname) {
        router.push(route).catch(err => {
          // 忽略导航失败错误，如：导航重复等
          if (err.name !== 'NavigationDuplicated') {
            console.error(err);
          }
        });
      }
    } catch (error) {
      location.reload()
    }
  }
});

</script>

<style scoped>
#app {
  width: 100%;
  padding: 10px 15px 0px;
}

:deep(.el-table__cell) {
  padding: 5px 0px;
}
</style>
